Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | import { appGetLayout } from "components/AppRoute"; import NotFoundPage from "features/NotFoundPage"; import LeaveReferencePageComponent from "features/profile/view/leaveReference/LeaveReferencePage"; import { GLOBAL, PROFILE } from "i18n/namespaces"; import { translationStaticProps } from "i18n/server-side-translations"; import { GetStaticPaths, GetStaticProps } from "next"; import { useRouter } from "next/router"; import { referenceStepStrings, referenceTypeRouteStrings } from "routes"; export const getStaticPaths: GetStaticPaths = () => ({ paths: [], fallback: "blocking", }); export const getStaticProps: GetStaticProps = translationStaticProps([ GLOBAL, PROFILE, ]); export default function LeaveReferencePage() { const router = useRouter(); // leave-reference/:type/:userId/:hostRequestId? // leave-reference/friend/:userId/:step? // leave-reference/surfed|hosted/:userId/:hostRequestId/:step? const slug = router.query.slug; Iif (!slug?.[0] || !slug?.[1]) return <NotFoundPage />; const referenceType = slug[0]; const parsedReferenceType = referenceTypeRouteStrings.find( (valid) => referenceType === valid ); Iif (!parsedReferenceType) return <NotFoundPage />; const parsedUserId = Number.parseInt(slug[1]); Iif (isNaN(parsedUserId)) return <NotFoundPage />; let step: string | undefined = undefined; let hostRequestId = undefined; if (parsedReferenceType === "friend") { step = slug?.[2]; } else { hostRequestId = slug?.[2]; Iif (!hostRequestId) return <NotFoundPage />; step = slug?.[3]; } const parsedStep = referenceStepStrings.find((s) => s === step); const parsedHostRequestId = hostRequestId ? Number.parseInt(hostRequestId) : undefined; return ( <LeaveReferencePageComponent referenceType={parsedReferenceType} userId={parsedUserId} hostRequestId={parsedHostRequestId} step={parsedStep} /> ); } LeaveReferencePage.getLayout = appGetLayout(); |